#pragma once
#include <d3dAppForm.h>
#include <D3DAddOn.h>
#include <d3dmodel.h>

class CD3DFont;
class ToolCamera;
class CEffect;
class CFXDialog;

#define D3DFVF_GRIDVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
#define D3DFVF_WALLVERTEX (D3DFVF_XYZ|D3DFVF_TEX1)
#define D3DFVF_GRIDVERTEX2 (D3DFVF_XYZ|D3DFVF_DIFFUSE)
class ToolApp : public CD3DAppForm
{
public:
	ToolApp(void);
	~ToolApp(void);

	struct GRIDVERTEX
	{
		FLOAT x, y, z;
		DWORD color;	
	};
	struct WALLVERTEX
	{
		WALLVERTEX()
		{
			nx = 0.0f;
			ny = 1.0f;
			nz = 0.0f;
		}
		FLOAT x, y, z;
		FLOAT nx, ny, nz;
		float tu, tv;
	};


	bool			isShadow;
	ToolCamera				*m_pCamera;
	LPDIRECT3DVERTEXBUFFER9		m_GridVB;
	LPDIRECT3DVERTEXBUFFER9		m_WallVB;
	LPDIRECT3DTEXTURE9			walls;
	LPD3DXRENDERTOSURFACE   SCRRENDER;
	LPDIRECT3DSURFACE9      SCRSURF;
	TextureItem* SCRTEX;
	ANILIST*	m_curAni;
	ANILIST*	m_curFaceAni;
	AddOnContainer* m_CurItem;
	int sex;

public:
	static ToolApp* CreateToolAppForm( HWND hWnd );
	void ToolApp::CreateGridAndWall();
	INT Run();
	virtual HRESULT Render3DEnvironment();
	virtual HRESULT Render3DEnvironment( HWND hwnd, int width, int height );
	HRESULT Render();
	void ToolApp::RenderR(SDrawElement *pdeCur);
	HRESULT ToolApp::DrawFrames(SFrame *pframeCur, UINT &cTriangles);
};
